package com.luke.springcloud.config;

import feign.*;
import org.springframework.context.annotation.Bean;

/**
 * @Descrtption MyFeignConfig
 * @Author luke
 * @Date 2020/5/12
 **/
public class MyFeignConfig {

    //Feign 日志级别
    @Bean
    public Logger.Level level(){
        return Logger.Level.FULL;
    }


    //超时策略
    /*@Bean
    public Request.Options options(){
        return new Request.Options(20000,20000); //超时策略
    }*/

    /**重试策略，默认不重试*/
    @Bean
    public Retryer feignRetryer(){
        Retryer retryer = new Retryer.Default(1000, 10000, 5);
        return retryer;
    }

    //拦截器
    @Bean
    public RequestInterceptor requestInterceptor(){
        return requestTemplate -> {
            requestTemplate.header("username", "luke");
        };
    }

}
